<template>
  <a-locale-provider :locale="lang">
    <div id="app" :class="ownStyle">
      <router-view v-if="isRouterAlive"></router-view>
    </div>
  </a-locale-provider>
</template>

<script>
export default {
  name: "app",
  provide() {
    return {
      reload: this.reload
    };
  },
  data() {
    return {
      isRouterAlive: true
    };
  },
  computed: {
    // 绑定到#app元素上的class
    ownStyle() {
      return this.$store.getters.companyInfo.setStyle;
    },
    lang() {
      return this.$t("antLocale");
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(function() {
        this.isRouterAlive = true;
      });
    }
  },
  mounted() {
    //解决路由变更 页面不变问题
    window.addEventListener(
      "hashchange",
      () => {
        let currentPath = window.location.hash.slice(1);
        if (this.$route.path !== currentPath) {
          this.$router.push(currentPath);
        }
      },
      false
    );
  }
};
</script>
